<?php

namespace app\api\controller;


use app\api\mdl\MdlAuto;
use lib\libRemoveImgFileToQiniu;
use lib\libSms;
use lib\libTool;
use lib\libVar;

class Auto
{
    //发送下单提醒
    public function sendUserSms()
    {
        $mdl = new MdlAuto();
        $mdl->sendSmsToRedis();
    }

    //短信存储
    public function saveUserSmsToRedis()
    {
        $mdl = new MdlAuto();
        $mdl->saveSendSms();
    }

    //校验性别
    public function updateSex()
    {
        $mdl = new MdlAuto();
        $mdl->updateSex();
    }

    public function sendUserMessage()
    {
        $mdl = new MdlAuto();
        $mdl->sendMessage();
    }

    //php /Server/app/public/index.php api/setGoodSid >> /Server/app/runtime/log/setGoodSid-`date +"%Y-%m-%d"`.log 2>&1
    public function setGoodSid()
    {
        return FALSE;
        $mdl = new MdlAuto();
        $mdl->setGoodSid();
    }

    //更新accessToken
    //php /Server/app/public/index.php api/updateAccessToken >> /Server/app/runtime/log/updateAccessToken-`date +"%Y-%m-%d"`.log 2>&1
    public function updateAccessToken()
    {
        $mdl = new MdlAuto();
        for ($i = 0; $i < 20; $i++) {
            $res = $mdl->updateAccessToken();
            if ($res != -1) {
                break;
            }
        }
    }

    //撤单
    public function cancelOrder()
    {
        $mdl = new MdlAuto();
        $mdl->cancelOrder();

    }

    //检测账号
    public function checkPhoneToZzd()
    {
        return FALSE;
        $mdl = new MdlAuto();
        $mdl->checkPhone();
    }

    //统计累积赚取
    public function sumCountCoin()
    {
        return FALSE;
        $mdl = new MdlAuto();
        $mdl->sumCountCoin();
    }

    /**
     *运行
     php /server/app/public/index.php api/remove_img >> /server/app/runtime/log/remove_img-`date +"%Y-%m-%d"`.log 2>&1
     * 头像图片和身份证
     * 表 ：tbs_member_buyer
     * 字段：avatar    idcardimgurl  idcardimgurl2  idcardimgurl3
     *
     * 账号审核图片
     * 表：tbs_member_buyer_platform_info
     * 字段：["credit_rating_img_url","realname_verify_img_url","huabei_img_url","jd_img_url"]
     *
     */
    public function test()
    {
        $isCli = preg_match("/cli/i", php_sapi_name()) ? TRUE : FALSE;
        if (!$isCli) {
            echo "当前只能使用cli运行";
         //   exit();
        }
        $mdl = new MdlAuto();
        $table = "tbs_member_buyer";//定义表名称
        //定义字段名
        $fieldArray = ["avatar", "idcardimgurl", "idcardimgurl2", "idcardimgurl3"];
        $primaryKey="userid";
        $mdl->removeImgFile($table,$fieldArray,$primaryKey);
    }
  //账号验证信息图片
    public function test2()
    {
        $isCli = preg_match("/cli/i", php_sapi_name()) ? TRUE : FALSE;
        if (!$isCli) {
            echo "当前只能使用cli运行";
            exit();
        }
        $mdl = new MdlAuto();
        $table = "tbs_member_buyer_platform_info";//定义表名称
        //定义字段名
        $fieldArray = ["credit_rating_img_url","realname_verify_img_url","huabei_img_url","jd_img_url"];
        $primaryKey="id";
        $mdl->removeImgFile($table,$fieldArray,$primaryKey);
    }  

    //把买手加入限制，一条线下的买手
    public function addLimitToUserid()
    {
        return FALSE;
        //0:查看用户 1:拉黑 2:限制接单
        $mode = libVar::param("mode")->toInt();
        $uid = libVar::param("uid")->toInt();
        $mdl = new MdlAuto();
        $mdl->addLimitToUserid($uid, $mode);
        $mdl->addLimit($mode, $uid);
    }
}
